import React, { useEffect } from 'react'
import { useNavigate ,useParams,useSearchParams} from 'react-router-dom'

function Index() {
  const navigate = useNavigate() //useNavigate hook
  const [searchParams,setSearchParams]=useSearchParams()
  const handleToIndex = () => {//编程式导航
    navigate('/home')
  }

  useEffect(()=>{
    console.log();
  })
  const handleAddParams=()=>{
    setSearchParams({
      name:'fieemiracle'
    })
  }
  return (
    <div>
      <h2 onClick={handleAddParams}>Index Page</h2>
      <button onClick={handleToIndex}>to Index</button>
    </div>
  )
}

export default Index